import { observable, reaction, action, computed, autorun,runInAction } from 'mobx'

class Store {
  state = {
    name: ''
  }
  @observable arr = [];
  @observable obj = { a: 1 }
  @observable map = new Map()
  @observable str = "hello"
  @observable num = 10;
  @observable bool = false;


  @action
  bar() {
    this.str = "hello world"
    this.num = 100
  }

  @computed
  get result() {
    return this.str + this.num;
  }

  @action
  async fzz() {
    await new Promise((resolve) => {
      setTimeout(() => {
        // this.num = 100;
        resolve(0)
      }, 3000)
    })
    
    // runInAction(()=>{
    //   this.num = 100
    // })
    
  }

}

const store = new Store()

autorun(() => {
  console.log(store.num)
})

store.num=1000;